package com.heima.wemedia.controller.v1;

import com.heima.model.comment.dtos.CommentLikeDto;
import com.heima.model.comment.dtos.CommentManageDto;
import com.heima.model.comment.dtos.CommentRepaySaveDto;
import com.heima.model.comment.dtos.CommentStatusDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.wemedia.service.CommentManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: CommentController
 * Description:
 * date: 2023/8/30 0030 17:08
 *
 * @author zHan
 */
@RestController
@RequestMapping("/api/v1/comment/manage")
@Api(tags = "自媒体端评论管理相关接口")
public class CommentController {

    @Autowired
    private CommentManageService commentManageService;

    /**
     * 查询评论列表
     *
     * @param dto
     * @return
     */
    @PostMapping("/find_news_comments")
    @ApiOperation("查询评论列表")
    public ResponseResult findNewsComments(@RequestBody CommentManageDto dto) {
        return commentManageService.findNewsComments(dto);
    }

    /**
     * 查看文章详情
     *
     * @param dto
     * @return
     */
    @PostMapping("/list")
    @ApiOperation("查看文章详情")
    public ResponseResult list(@RequestBody CommentManageDto dto) {
        return commentManageService.list(dto);
    }

    /**
     * 打开或关闭评论
     *
     * @param dto
     * @return
     */
    @PostMapping("/update_comment_status")
    @ApiOperation("打开或关闭评论")
    public ResponseResult updateCommentStatus(@RequestBody CommentStatusDto dto) {
        return commentManageService.updateCommentStatus(dto);
    }

    /**
     * 回复评论
     *
     * @param dto
     * @return
     */
    @PostMapping("/comment_repay")
    @ApiOperation("回复评论")
    public ResponseResult commentRepay(@RequestBody CommentRepaySaveDto dto) {
        return commentManageService.commentRepay(dto);
    }

    /**
     * 评论点赞
     *
     * @return
     */
    @PostMapping("/like")
    @ApiOperation("评论点赞")
    public ResponseResult like(@RequestBody CommentLikeDto dto) {
        return commentManageService.like(dto);
    }

    /**
     * 删除评论
     * @param commentId
     * @return
     */
    @DeleteMapping("/del_comment/{commentId}")
    @ApiOperation("删除评论")
    public ResponseResult deleteComment(@PathVariable String commentId) {
        return commentManageService.deleteComment(commentId);
    }

    /**
     * 删除评论回复
     * @param commentRepayId
     * @return
     */
    @DeleteMapping("/del_comment_repay/{commentRepayId}")
    @ApiOperation("删除评论回复")
    public ResponseResult deleteCommentRepay(@PathVariable String commentRepayId) {
        return commentManageService.deleteCommentRepay(commentRepayId);
    }


}
